package com.kaifamiao.thread.d0926;

public class MyThread extends Thread {

    public MyThread(){
        super("自定义线程");
    }

    public MyThread(String name){
        super(name);
    }

    public MyThread(Runnable t){
        super(t);
    }

    private Thread t;
    public MyThread(String name, Thread t){
        super(name);
        this.t = t;
    }

    @Override
    public void run() {
        try {
            Thread.sleep(5000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        int i = 0;
        while(!isInterrupted()) {
            if (i == 100){
                interrupt();
            }
            System.out.println(getName()+"：正在执行！"+i ++ + ", 线程状态: " + getState());
        }
    }

}
